<?xml version="1.0" encoding="UTF-8"?>
<html>
<title>JVM interpreter in JavaScript</title>
<br>

<input type="button" onclick="startInterpret()" value="start" />
<!--input type="file" id="fileinput"/-->

<br><br>
<textarea id="parse" name="parse" cols="100" rows="20" > </textarea> 
<textarea id="binary" name="binary" cols="100" rows="20" > </textarea> 

<script type="text/javascript" src="util.js"></script>

<script type="text/javascript" src="Operand.js"></script>
<script type="text/javascript" src="paths.js"></script>
<script type="text/javascript" src="Class.js"></script>
<script type="text/javascript" src="Frame.js"></script>
<script type="text/javascript" src="Exception.js"></script>
<script type="text/javascript" src="parse.js"></script>
<script type="text/javascript" src="ClassLoader.js"></script>
<script type="text/javascript" src="OpExecuter.js"></script>
<script type="text/javascript" src="Interpreter.js"></script>

<script type="text/javascript" src="init.js"></script>

<script type="text/javascript">
	function startInterpret()
	{
		var full_path = prompt("Please enter the full path of your class without \".class\"\n(e.g. \"D:\\project\\HelloWorld\" or \"~/prog/HelloWorld\")", 
			"/Users/ksung/691ST/jvm-umasscs/SourceCode/jie/test/HelloWorld");
		if (full_path == null) {
			alert("please enter a valid path");
			return;
		}
		for (var i = full_path.length - 1; i >= 0; --i) if (full_path[i] == the_slash) {
			the_paths.addPath(full_path.substring(0, i + 1));
			//alert(the_paths.paths[0]);
			the_itpt.interpret(full_path.substring(i + 1, full_path.length), null);
			break;
		}
		
	}
	/*
	function convertToBinaryFile(classFile) {
		var binaryFile = new Array();
		var len = classFile.length;
		for (var i = 0; i < len; ++i) binaryFile[i] = classFile.charCodeAt(i) & 0xff;
		return binaryFile;
	}

	function readSingleFile(evt) {
	//Retrieve the first (and only!) File from the FileList object
		var f = evt.target.files[0];
		for (var idx in f) {
			alert(idx + ": " + f[idx]);
			for (var ii in f[idx]) alert(idx + ":: " + f[idx][ii]);
		}
		var class_name = (f.name.split("."))[0];
		alert("class name: " + class_name);
		the_interpreter.interpret(class_name, null); //TODO!! arguments
		
		
		var contents = null;
		if (f) {
			var r = new FileReader();
			r.onload = function(e) { 
				contents = e.target.result;
				try {
					var result = tryParseBinaryClassFile(convertToBinaryFile(contents));
					//document.getElementById('parse').value = result;
				}
				catch (e) {
					alert(e);
					document.getElementById('parse').value = e;
				}
				
				//document.getElementById('show').value=contents;
			}
			r.readAsText(f);      
		} else { 
			alert("Failed to load file");
		}
		//alert(parseResult);
		//alert(parseResult.major);
		//alert(sss);
		return contents;
	}
	document.getElementById('fileinput').addEventListener('change', readSingleFile, false);
	*/
	
</script>



</html>